import Vue from 'vue'
import Vuex from 'vuex'
import TodoMain from './modules/TodoMain'
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex)


export default new Vuex.Store({
  modules:{
    TodoMain,
  },
  
  getters: {
    TodoMain(state){
      return state.TodoMain.TodoMain
    },
    TodoList: (state) => {
      return state.TodoMain.TodoMain.filter(item=>item.done===false)
    },
    DoneList: (state) => {
      return state.TodoMain.TodoMain.filter(item=>item.done===true)
    },
    ShowList:(state, getters) => {
      if (state.TodoMain.mainkey == 'all') {
        return getters.TodoMain
      } else if (state.TodoMain.mainkey == 'todo') {
        return getters.todoList
      } else {
        return getters.doneList
      }
    },
  },
  plugins: [createPersistedState({})],
})